#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    FILE *fp;
    char data[BUFSIZ];
    char *input_filename;
    size_t bytes_to_be_read;

    if (argc!=3)
        error_at_line(EXIT_FAILURE, 0, __FILE__, __LINE__,
                "FATAL ERROR: Wrong number of arguments.\n"
                "Usage: %s <input_filename> <bytes_to_be_read>", argv[0]);

    input_filename = argv[1];
    bytes_to_be_read = atoi(argv[2]);

    if ((fp = fopen(input_filename, "r")) == NULL)
        error_at_line(EXIT_FAILURE, errno, __FILE__, __LINE__,
                "FATAL ERROR: %s", input_filename);

    printf("%zu byte(s) read.\n", fread(data, sizeof(data),
                bytes_to_be_read, fp));

    /*
    printf("%zu byte(s) read.\n", fread(data, sizeof(data[0]),
                bytes_to_be_read, fp));
                */

    if (feof(fp))
        printf("EOF reached\n");

    exit(EXIT_SUCCESS);
}
